package com.imti.util;

import java.util.List;

/**
 * 分页
 */
public class PageBean {
    private Integer totalCount=0;//总条数
    private Integer totalPage=0;//总页数
    private Integer currtPage=1;//当前页码
    private Integer pageLimit=5;//每页显示条数
    private Integer pageIndex=0;//分页索引下标
    private List<?> list;//存放列表数据
    private String url;//不同业务模块请求地址
    private String params;//搜索所需要的参数 &a=1&b=2&c=3

    /**
     * @param totalCount 总条数
     * @param currtPage 当前页码
     * @param pageLimit 每页条数
     * @param list 集合列表
     */
    public PageBean(Integer totalCount, Integer currtPage, Integer pageLimit, List<?> list, String url, String params) {
        this.totalCount = totalCount;
        this.currtPage = currtPage;
        this.pageLimit = pageLimit;
        this.list = list;
        this.url = url;
        this.params = params;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getParams() {
        return params;
    }

    public void setParams(String params) {
        this.params = params;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getTotalPage() {
        if(pageLimit==null || pageLimit<=0){
            pageLimit=5;
        }
        return totalCount%pageLimit==0?totalCount/pageLimit:totalCount/pageLimit+1;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public Integer getCurrtPage() {
        return currtPage;
    }

    public void setCurrtPage(Integer currtPage) {
        this.currtPage = currtPage;
    }

    public Integer getPageLimit() {
        return pageLimit;
    }

    public void setPageLimit(Integer pageLimit) {
        this.pageLimit = pageLimit;
    }

    public Integer getPageIndex() {
        if(currtPage<=0){
            currtPage=1;
        }
       return (currtPage-1)*pageLimit;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public List<?> getList() {
        return list;
    }

    public void setList(List<?> list) {
        this.list = list;
    }
}
